package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.DBDataClass.CrowdCompanyDataClass;
import com.limao.DBProvider.CrowdCompanyProvider;
import com.limao.cache.BasicModule;

public class CrowdCompanyCache extends BasicModule{

	private CrowdCompanyProvider provider;
	private static CrowdCompanyCache instance;

	public static CrowdCompanyCache getInstance() {
		return instance;
	}

	private Cache<String, CrowdCompanyDataClass> crowdCompanyCache;

	public CrowdCompanyCache() {
    	super("CrowdCompanyCache");
    	crowdCompanyCache = CacheFactory.createCache("sys_crowd_CompanyCache");
		initProvider();
	}
    
    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
	
    public void ClearObjectCache()
    {
   		crowdCompanyCache.clear();
    } 
  
	
    public CrowdCompanyDataClass  load_CompanyByUserid(int userid)
    {
    	return provider.load_CompanyByUserid(userid);
    } 
	
    
    public boolean  add_Company(String userid,String companylogo,String iscompany,String companyname,String companyman,
    		String mancardimg0,String mancardimg1,String companycardimg,String address,String tel,String telman,String intro,String introimg,String qq,String mancardno,String companyno)
	{
    	
    	return provider.add_Company(userid,companylogo,iscompany,companyname,companyman,
    			mancardimg0,mancardimg1,companycardimg,address,tel,telman,intro,introimg,qq,mancardno,companyno);
	}
	
    public boolean  add_CompanyPay(int companyid,int paytype,float authcompayrmb,String payimage)
    {
    	return provider.add_CompanyPay(companyid,paytype,authcompayrmb,payimage);
    	
    }
    

	//**************************************************************************************************/	
	private void initProvider() {
		if (provider == null) {
			try {
				provider = CrowdCompanyProvider.getInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	

}
